﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="PublicProspecting.aspx.cs" Inherits="House客户端.PublicProspecting" %>

<!DOCTYPE html>
<html>
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
    <style type="text/css">
        body, html {
            width: 100%;
            height: 100%;
            margin: 0;
            font-family: "微软雅黑";
        }

        #allmap {
            height: 300px;
            width: 100px;
        }

        #r-result {
            width: 100%;
            font-size: 14px;
        }
    </style>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>公共区域勘察页面</title>
    <link href="easyui/easyui/1.3.4/themes/default/easyui.css" rel="stylesheet" />
    <link href="easyui/easyui/1.3.4/themes/icon.css" rel="stylesheet" />
    <link href="easyui/easyui/1.3.4/demo/demo.css" rel="stylesheet" />
</head>
<body>
    <form id="form1" runat="server"></form>
    <div class="easyui-panel" fit="true">
        <table>
            <tr>
                <td>所在楼号</td>
                <td>
                    <input type="text" class="easyui-textbox" id="Number" style="width: 800px;" required />
                    <span id="sp1" style="color: red"></span></td>

            </tr>
            <tr>
                <td>地图</td>
                <td>
                    <div id="allmap" class="easyui-textbox" style="width: 800px; height: 350px;"></div>
                </td>
            </tr>
            <tr>
                <td>定位坐标</td>
                <td>
                    <input type="text" class="easyui-textbox" id="Landmark" style="width: 800px;" /><span id="sp2" style="color: red"></span></td>

            </tr>
            <tr>
                <td>定位地址</td>
                <td>
                    <input type="text" required class="easyui-textbox" id="Address" style="width: 800px;" />
                    <span id="sp3" style="color: red"></span>
                </td>

            </tr>
            <tr>
                <td>房屋结构</td>
                <td>
                    <select id="HouseStructure" class="easyui-combobox" required style="width: 800px;">
                        <option value="请选择房屋结构"></option>
                    </select>
                </td>
            </tr>
            <tr>
                <td>建筑类型</td>
                <td>
                    <select id="BuildType" class="easyui-combobox" required style="width: 800px;">
                        <option value="请选择建筑类型"></option>
                    </select>
                </td>
            </tr>
            <tr>
                <td>外立面装饰</td>
                <td>
                    <select id="Facade" class="easyui-combobox" required style="width: 800px;">
                        <option value="请选择外立面装饰"></option>
                    </select>
                </td>
            </tr>
            <tr>
                <td>公共部位装饰</td>
                <td>
                    <select id="Public" class="easyui-combobox" required style="width: 800px;">
                        <option value="请选择公共部位装饰"></option>
                    </select>
                </td>
            </tr>
            <tr>
                <td>电梯</td>
                <td>
                    <select id="Lift" class="easyui-combobox" required style="width: 800px;">
                        <option value="请选择有无电梯"></option>
                    </select>
                </td>
            </tr>
            <tr id="num">
                <td>电梯个数</td>
                <td>
                    <select id="LiftNum" class="esayui-combobox" required style="width: 800px;">
                        <option value="0">请选择电梯个数</option>
                        <option value="1">1</option>
                        <option value="2">2</option>
                        <option value="3">3</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td>供气</td>
                <td>
                    <select id="Gas" class="easyui-combobox" required style="width: 800px;">
                        <option value="请选择供气"></option>
                    </select>
                </td>
            </tr>
            <tr>
                <td>供水</td>
                <td>
                    <select id="Water" class="easyui-combobox" required style="width: 800px;">
                        <option value="请选择供水"></option>
                    </select>
                </td>
            </tr>
            <tr>
                <td>供暖</td>
                <td>
                    <select id="Warm" class="easyui-combobox" required style="width: 800px;">
                        <option value="请选择供暖"></option>
                    </select>
                </td>
            </tr>
            <tr>
                <td>门禁系统</td>
                <td>
                    <select id="Door" class="easyui-combobox" required style="width: 800px;">
                        <option value="请选择门禁"></option>
                    </select>
                </td>
            </tr>
            <tr>
                <td>其他说明</td>
                <td>
                    <textarea id="Explain" required class="easyui-textbox" style="width: 800px;"></textarea>
                    <span id="sp4" style="color: red"></span></td>
            </tr>
            <tr>
                <td>勘察时间</td>
                <td>
                    <input id="time" class="easyui-textbox" required type="date" style="width: 800px;" />

                </td>
            </tr>
            <tr>
                <td>
                    <button onclick="funbao()">保存</button></td>
            </tr>


        </table>
    </div>
    <script src="easyui/easyui/1.3.4/jquery.min.js"></script>
    <script src="easyui/easyui/1.3.4/jquery.easyui.min.js"></script>
    <script src="jquery-easyui-1.5.2/jquery.params.js"></script>
    <script src="jquery-easyui-1.5.2/Common.js"></script>
    <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=SexdjnRlxkNpCyStSosBPeYAxFPn5acx"></script>
    <script>
        //绑定房屋结构
        HouseStructure();
        function HouseStructure() {
            $.ajax({
                type: "get",
                url: WebApiURL + "api/Dictionary/?type=" + "房屋结构" + "&i=" + 14,
                success: function (obj) {
                    obj = eval(obj);
                    $("#HouseStructure").combobox({
                        editable: false,
                        data: obj,
                        valueField: "ID",
                        textField: 'Dictionary_Name'
                    });
                }
            })
        }
        //绑定建筑类型
        BuildType();
        function BuildType() {
            $.ajax({
                type: "get",
                url: WebApiURL + "api/Dictionary/?type=" + "建筑类型" + "&i=" + 15,
                success: function (obj) {
                    obj = eval(obj);
                    $("#BuildType").combobox({
                        editable: false,
                        data: obj,
                        valueField: "ID",
                        textField: 'Dictionary_Name'
                    });
                }
            })
        }
        //绑定外立面装饰
        Facade();
        function Facade() {
            $.ajax({
                type: "get",
                url: WebApiURL + "api/Dictionary/?type=" + "外立面装饰" + "&i=" + 16,
                success: function (obj) {
                    obj = eval(obj);
                    $("#Facade").combobox({
                        editable: false,
                        data: obj,
                        valueField: "ID",
                        textField: 'Dictionary_Name'
                    });
                }
            })
        }
        //绑定公共部位装修
        Public();
        function Public() {
            $.ajax({
                type: "get",
                url: WebApiURL + "api/Dictionary/?type=" + "公共部位装修" + "&i=" + 17,
                success: function (obj) {
                    obj = eval(obj);
                    $("#Public").combobox({
                        editable: false,
                        data: obj,
                        valueField: "ID",
                        textField: 'Dictionary_Name'
                    });
                }
            })
        }
        //绑定电梯
        Lift();
        function Lift() {
            $.ajax({
                type: "get",
                url: WebApiURL + "api/Dictionary/?type=" + "电梯" + "&i=" + 18,
                success: function (obj) {
                    obj = eval(obj);
                    $("#Lift").combobox({
                        editable: false,
                        data: obj,
                        valueField: "ID",
                        textField: 'Dictionary_Name',
                        onChange: function (dianti) {
                            have(dianti);
                        }
                    });
                }
            })
        }
        function have(dianti) {
            if (dianti == 66) {
                $("#num").hide();
            }
            else {
                $("#num").show();
            }
        }
        //绑定供气
        Gas();
        function Gas() {
            $.ajax({
                type: "get",
                url: WebApiURL + "api/Dictionary/?type=" + "供气" + "&i=" + 19,
                success: function (obj) {
                    obj = eval(obj);
                    $("#Gas").combobox({
                        editable: false,
                        data: obj,
                        valueField: "ID",
                        textField: 'Dictionary_Name'
                    });
                }
            })
        }
        //绑定供水
        Water();
        function Water() {
            $.ajax({
                type: "get",
                url: WebApiURL + "api/Dictionary/?type=" + "供水" + "&i=" + 20,
                success: function (obj) {
                    obj = eval(obj);
                    $("#Water").combobox({
                        editable: false,
                        data: obj,
                        valueField: "ID",
                        textField: 'Dictionary_Name'
                    });
                }
            })
        }
        //绑定供暖
        Warm();
        function Warm() {
            $.ajax({
                type: "get",
                url: WebApiURL + "api/Dictionary/?type=" + "供暖" + "&i=" + 21,
                success: function (obj) {
                    obj = eval(obj);
                    $("#Warm").combobox({
                        editable: false,
                        data: obj,
                        valueField: "ID",
                        textField: 'Dictionary_Name'
                    });
                }
            })
        }
        //绑定门禁系统
        Door();
        function Door() {
            $.ajax({
                type: "get",
                url: WebApiURL + "api/Dictionary/?type=" + "门禁系统" + "&i=" + 22,
                success: function (obj) {
                    obj = eval(obj);
                    $("#Door").combobox({
                        editable: false,
                        data: obj,
                        valueField: "ID",
                        textField: 'Dictionary_Name'
                    });
                }
            })
        }
        var map = new BMap.Map("allmap");            // 创建Map实例
        var point = new BMap.Point(116.404, 39.915); // 创建点坐标
        map.addControl(new BMap.MapTypeControl());   //添加地图类型控件
        map.setCurrentCity("北京");          // 设置地图显示的城市 此项是必须设置的
        map.centerAndZoom(point, 15);     //以当前坐标为中心点
        map.enableScrollWheelZoom(true);                 //启用滚轮放大缩小
        map.addControl(new BMap.NavigationControl());
        map.addControl(new BMap.ScaleControl());
        map.addControl(new BMap.OverviewMapControl());
        map.addControl(new BMap.MapTypeControl());
        map.setCurrentCity("北京");// 仅当设置城市信息时，MapTypeControl的切换功能才能可用
        //创建标注
        var marker = new BMap.Marker(point);
        //将标注添加到地图中
        map.addOverlay(marker);
        //给地图添加单击事件
        map.addEventListener("click", function (e) {
            //点击一下  去掉标注
            map.removeOverlay(marker);
            point = new BMap.Point(e.point.lng, e.point.lat);
            marker = new BMap.Marker(point);
            map.addOverlay(marker);
            map.centerAndZoom(point, 15);
            var di = "";
            di += e.point.lng;
            di += ",";
            di += e.point.lat;
            $("#Landmark").val(di);
            $.ajax({
                type: "put",
                url: WebApiURL + "api/Values/Upt/?id=" + 1,
                success: function (obj) {
                    if (obj > 0) {
                        return "";
                    }
                    else {
                        return "";
                    }
                }
            })
        });
        function funbao() {
            var ProjectNumber = $.query.get("ProjectNumber");
            var Number = $("#Number").val();
            if (Number == "" || Number == null) {
                $("#sp1").html("不能为空");
                return;
            } else {
                $("#sp1").html("");
            }
            var Landmark = $("#Landmark").val();
            if (Landmark == "" || Landmark == null) {
                $("#sp2").html("不能为空");
                return;
            } else {
                $("#sp2").html("");
            }
            var Address = $("#Address").val();
            if (Address == "" || Address == null) {
                $("#sp3").html("不能为空");
                return;
            } else {
                $("#sp3").html("");
            }
            var HouseStructure = $('#HouseStructure').combobox('getValue');
            var BuildType = $('#BuildType').combobox('getValue');
            var Facade = $('#Facade').combobox('getValue');
            var Public = $('#Public').combobox('getValue');
            var Lift = $('#Lift').combobox('getValue');
            var LiftNum = $("#LiftNum").val();
            var Gas = $('#Gas').combobox('getValue');
            var Water = $('#Water').combobox('getValue');
            var Warm = $('#Warm').combobox('getValue');
            var Door = $("#Door").combobox('getValue');
            var Explain = $("#Explain").val();
            if (Explain == "" || Explain == null) {
                $("#sp4").html("不能为空");
                return;
            } else {
                $("#sp4").html("");
            }
            var time = $("#time").val();
            $.ajax({
                type: "post",
                url: WebApiURL + "api/Values/door",
                data: {
                    ProjectNumber: ProjectNumber,
                    Floor_Number: Number,
                    Floor_Landmark: Landmark,
                    Floor_Address: Address,
                    Floor_HouseStructure: HouseStructure,
                    Floor_BuildType: BuildType,
                    Floor_Facade: Facade,
                    Floor_Public: Public,
                    Floor_Lift: Lift,
                    Floor_LiftNum: LiftNum,
                    Floor_Gas: Gas,
                    Floor_Water: Water,
                    Floor_Warm: Warm,
                    Floor_Door: Door,
                    Floor_Explain: Explain,
                    Floor_CreateTime: time
                },
                success: function (obj) {
                    if (obj > 0) {
                        $.messager.alert("勘察成功");
                        location.href = 'ProspectingList.aspx';

                    }
                    else {
                        $.messager.alert("勘察失败");
                        location.href = 'PublicProspecting.aspx';
                    }
                }
            })
        }
    </script>
</body>
</html>
